#!/bin/sh

ifname=$(uci -q get network.lte)
[ -n "$ifname" ] && return

uci batch <<EOF
set network.lte='interface'
set network.lte.proto='dhcp'
set network.lte.ifname='wwan0'
set network.lte.defaultroute='1'
set network.lte.metric='10'
commit network
EOF

# if the lte interface already exists in list network of firewall zone,
# do not execute the add_list command to avoid duplicate interfaces.
ifaces=$(uci -q get firewall.@zone[1].network)
exist="false"
[ -n "$ifaces" ] && {
    iface="tmp_val"
    i=1
    while [ -n "$iface" ]; do
        iface=$(echo $ifaces|cut -d ' ' -f $i)
        let i=i+1
        [ "$iface" = "lte" ] && exist="true"
    done
}
[ "$exist" = "false" ] && {
    uci add_list firewall.@zone[1].network='lte'
    uci commit firewall
}
board=$(board_name)

case "$board" in
        fsl,imx6ul-14x14-evk)
        uci set lteconfig.lteconfig.delay='50'
        uci commit lteconfig
        ;;
esac

